<?php
/***
 * 
 * @author GuoLong
 * 2014/12/25
 * 
 */

class homework_feedback extends Model {
	
	private $table="xdf_homework_feedback";
	private $fields=array("");
	//学生获取一次作业当中一道题的反馈详情
	public function addHomeworkFeedback($homework_id,$user_id){
		$sql="INSERT INTO $this->table (`homework_id`,`student_id`,`state`,`create_time`)
		VALUES('$homework_id','$user_id',0,NOW());";
		return $this->insert($sql);
	}
	public function getMyHomeworkFeedbackByHomeworkId($homework_id,$user_id) {
		$sql="SELECT * FROM $this->table WHERE `homework_id`='$homework_id' AND `student_id`='$user_id';";
		return $this->fetchRow($sql);		
	}
	public function finishHomeworkFeedback($homework_id,$user_id){
		$sql="UPDATE $this->table SET `state`='1' WHERE `homework_id`='$homework_id' AND `student_id`='$user_id';";
		return $this->update($sql);
	}
	public function getHomeworkImageState($user_id,$homework_id){
		$sql="SELECT `state` as imagefeedback FROM $this->table WHERE `homework_id`='$homework_id' AND `student_id`='$user_id';";
		return $this->fetchRow($sql);		
	}
}
